<template>an
    <div class="container">
        <div class="cssBox">
            <div class="conLeft" @click="backHome">
                <img src="../../../assests/images/logo.png" alt="">
                <p>尚医通 预约挂号统一平台</p>
            </div>
            <div class="conRight">
                <p class="help">帮助中心</p>
                <p @click="loginReg" v-if="!userStore.userData?.token">登录/注册</p>
                <el-dropdown v-else>
                    <span class="el-dropdown-link">
                        {{ userStore.userData?.name }}
                        <el-icon class="el-icon--right">
                            <arrow-down />
                        </el-icon>
                    </span>
                    <template #dropdown>
                        <el-dropdown-menu>
                            <el-dropdown-item @click="goReal">实名认证</el-dropdown-item>
                            <el-dropdown-item @click="goOrder">挂号订单</el-dropdown-item>
                            <el-dropdown-item @click="goVisitor">就诊人管理</el-dropdown-item>
                            <el-dropdown-item @click="loyout">退出登录</el-dropdown-item>
                        </el-dropdown-menu>
                    </template>
                </el-dropdown>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useRouter, useRoute } from 'vue-router';
import { useUserStore } from '@/stores/modules/user/user'
let userStore = useUserStore()

let $router = useRouter()
let $route = useRoute()
const backHome = () => {

    $router.push({
        path: "/home",
    })
}

const loginReg = () => {
    if (userStore.token == '') {
        let redirect = $route.query.redirect
        console.log(redirect);
        
        $router.push({ path: '/home', query: { redirect:redirect} })
    }
    userStore.visDialog()
}
const loyout = () => {
    userStore.quitLogin()
    $router.push('/home')
}
// 跳转订单页面
const goOrder = () => { 
    $router.push('/user/order')
}
// 实名认证
const goReal = () => { 
    console.log(userStore.userData);
    
    $router.push('/user/real')
}
// 就诊人管理
const goVisitor = ()=>{
    $router.push('/user/visitor')
}

</script>

<style lang="scss" scoped>
p {
    cursor: pointer;
}

.container {
    height: 70px;
    background-color: #fff;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid #ccc;
    // 固定
    position: fixed;
    top: 0;
    z-index: 99;

    .cssBox {
        width: 1230px;
        height: 70px;
        display: flex;
        justify-content: space-between;

        .conLeft,
        .conRight {
            display: flex;
            align-items: center;
        }

        .conLeft {
            img {
                width: 50px;
                height: 50px;
            }

            p {
                margin-left: 10px;
                font-size: 20px;
                color: rgb(143, 187, 255);
            }
        }

        .conRight {
            .help {
                margin-right: 15px;
            }
        }
    }
}
</style>